package cn.wolfcode.crm.domain;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.Getter;
import lombok.Setter;

@Setter @Getter
public class Customer {
	private Long id;
	private String name; // 姓名
	private Integer age; // 年龄 0女1男
	private Integer gender; // 性别
	private String tel; // 电话
	private String qq; // qq
	private Long job_id; // 客户职业
	private Long source_id; // 客户来源
	private Long seller_id;	//业务员
	private Long inputUserId;
	private Date inputTime; // 录入时间
	private Integer status; // 客户状态 0潜在 1客户池 2开发失败 3流失 4正式客户

	private Employee seller;// 业务员
	private SystemDictionaryItem source;
	private SystemDictionaryItem job;

	// 把当前对象在数据转成JSON表格字符串
	public String getJson() throws JsonProcessingException {
		ObjectMapper mapper = new ObjectMapper();
		Map<String, Object> map = new HashMap<>();
		map.put("id", id);
		map.put("name", name);
		map.put("age", age);
		map.put("gender", gender);
		map.put("tel", tel);
		map.put("qq", qq);
		map.put("jobId", job_id);
		map.put("sourceId", source_id);
		map.put("sellerId", seller.getId());
		map.put("sellerName", seller.getName());
		return mapper.writeValueAsString(map);
	}

	public String getSellerName() {
		return seller.getName();
	}

	// 把数字转为字符串
	public String getGenderName() {
		return gender == 1 ? "男" : "女";
	}

	public String getStatusName() {
		String msg = "潜在客户";
		if (status == 1) {
			msg = "客户池";
		} else if (status == 2) {
			msg = "开发失败";
		} else if (status == 3) {
			msg = "流失";
		} else if (status == -1) {
			msg = "全部";
		} else if (status == 4) {
			msg = "正式客户";
		}
		return msg;
	}

	
//	  `inputUser_id` bigint(20) DEFAULT NULL,

}
